<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>327-2</title>
    <style>
        td {
            border: 1px solid;
        }

        #tbl {
            width: 300px;
            height: 200px;
        }
    </style>
</head>
<body>
<table id="tbl"></table>
<script>
    var persons = [
        {name: "张三", age: 23, sex: '男', zodiac: ''},
        {name: "老王", age: 60, sex: '男', zodiac: ''},
        {name: "桂香", age: 19, sex: '女', zodiac: ''},
        {name: "魏红", age: 33, sex: '女', zodiac: ''},
        {name: "二狗", age: 5, sex: '男', zodiac: ''}
    ];
    function showTable() {
        var str =`
        <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
        <th>生肖</th>
        </tr><!--表头-->
        `;
        for (i in persons) {
            str += `<tr>
        <td>${persons[i].name}</td>
        <td>${persons[i].age}</td>
        <td>${persons[i].sex}</td>
        <td>${persons[i].zodiac}</td>
        </tr>`;
            document.querySelector('#tbl').innerHTML = str;
        }
    }
    showTable();

    var Zodiac = ["狗", "鸡", "猴", "羊", "马", "蛇", "龙", "兔", "虎", "牛", "鼠", "猪"];


    function countZodiac(e) {
            var uAge = persons[i].age;
            var remainder = uAge % 12;
            persons[i].zodiac = Zodiac[remainder];

    }
    for(var i=0;i<persons.length;i++){
        countZodiac(i);
    }
    showTable();

    /*var sz=["零","壹","贰","叁","肆","伍","陆","柒","捌","玖" ];

    var szs="13343223";
    for(var i in sz){
        console.log(sz[szs[i]]);
    }  转大小写*/



</script>
</body>
</html>